﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Photon.SocketServer;
using Common;
using Common.Tools;
using Common.Model;

using MyGameServer.Manager;
using MyGameServer.Model;
using System.IO;
using System.Xml.Serialization;

namespace MyGameServer.Handler
{
    class RoomListHandler : BaseHandler
    {
        public RoomListHandler()
        {
            OpCode = OperationCode.RoomList;
        }
        public override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters, ClientPeer peer)
        {
            OperationResponse response = new OperationResponse(operationRequest.OperationCode);

            Dictionary<byte, object> data = new Dictionary<byte, object>();
            string roomListString = Functions.ObjectToXmlString<List<Room>>(MyGameServer.Instance.roomList);
            data.Add((byte)ParameterCode.RoomList, roomListString);
            response.Parameters = data;
            peer.SendOperationResponse(response, sendParameters);
        }
    }
}